|
|
@@ -1,9 +1,12 @@
|
1
|
1
|
package ai.pai.lensman.main;
|
2
|
2
|
|
|
3
|
+import android.content.BroadcastReceiver;
|
3
|
4
|
import android.content.ComponentName;
|
4
|
5
|
import android.content.Context;
|
5
|
6
|
import android.content.Intent;
|
|
7
|
+import android.content.IntentFilter;
|
6
|
8
|
import android.content.ServiceConnection;
|
|
9
|
+import android.net.ConnectivityManager;
|
7
|
10
|
import android.os.IBinder;
|
8
|
11
|
|
9
|
12
|
import com.android.common.utils.LogHelper;
|
|
|
@@ -31,6 +34,19 @@ public class MainPresenter implements MainContract.Presenter,BaseInteractor.Inte
|
31
|
34
|
private FetchSessionIdsInteractor interactor;
|
32
|
35
|
private ServiceConnection serviceConnection;
|
33
|
36
|
|
|
37
|
+ private BroadcastReceiver wifiReceiver = new BroadcastReceiver() {
|
|
38
|
+ @Override
|
|
39
|
+ public void onReceive(Context context, Intent intent) {
|
|
40
|
+ if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) {
|
|
41
|
+ if(NetworkUtil.isWifiConnected(context)){
|
|
42
|
+ uploadView.showBoxConnectedView();
|
|
43
|
+ }else{
|
|
44
|
+ uploadView.showBoxDisconnectedView();
|
|
45
|
+ }
|
|
46
|
+ }
|
|
47
|
+ }
|
|
48
|
+ };
|
|
49
|
+
|
34
|
50
|
public MainPresenter(MainContract.View view){
|
35
|
51
|
this.uploadView = view;
|
36
|
52
|
this.lensmanId = Preferences.getInstance().getLensManId();
|
|
|
@@ -74,15 +90,15 @@ public class MainPresenter implements MainContract.Presenter,BaseInteractor.Inte
|
74
|
90
|
uploadView.refreshSessionViews(sessionList);
|
75
|
91
|
}
|
76
|
92
|
sessionSeq = sessionList.size();
|
77
|
|
-
|
|
93
|
+ registerWifiChangeReceiver();
|
78
|
94
|
App.getAppContext().startService(new Intent(App.getAppContext(), UploadService.class));
|
79
|
95
|
App.getAppContext().bindService(new Intent(App.getAppContext(),UploadService.class),serviceConnection, Context.BIND_AUTO_CREATE);
|
80
|
|
- uploadView.showOrderSnackBar();
|
81
|
96
|
}
|
82
|
97
|
|
83
|
98
|
@Override
|
84
|
99
|
public void stop() {
|
85
|
100
|
App.getAppContext().unbindService(serviceConnection);
|
|
101
|
+ App.getAppContext().unregisterReceiver(wifiReceiver);
|
86
|
102
|
}
|
87
|
103
|
|
88
|
104
|
@Override
|
|
|
@@ -171,4 +187,11 @@ public class MainPresenter implements MainContract.Presenter,BaseInteractor.Inte
|
171
|
187
|
sessionBean.sessionPhotos = photoList;
|
172
|
188
|
uploadView.updateSessionUploadViewAt(position);
|
173
|
189
|
}
|
|
190
|
+
|
|
191
|
+ private void registerWifiChangeReceiver() {
|
|
192
|
+ IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
|
|
193
|
+ App.getAppContext().registerReceiver(wifiReceiver,filter);
|
|
194
|
+ }
|
|
195
|
+
|
|
196
|
+
|
174
|
197
|
}
|